/*
 *       This file is part of NWFramework.
 *       Copyright (c) InCrew Software and Others.
 *       (See the AUTHORS file in the root of this distribution.)
 *
 *       NWFramework is free software; you can redistribute it and/or modify
 *       it under the terms of the GNU General Public License as published by
 *       the Free Software Foundation; either version 2 of the License, or
 *       (at your option) any later version.
 *
 *       NWFramework is distributed in the hope that it will be useful,
 *       but WITHOUT ANY WARRANTY; without even the implied warranty of
 *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *       GNU General Public License for more details.
 * 
 *       You should have received a copy of the GNU General Public License
 *       along with NWFramework; if not, write to the Free Software
 *       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */
#include "PchDSNWStream.h"

#include "DSGraphSource.h"
#include "NWStreamGroup.h"

//********************************************************************
//
//********************************************************************
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
DSGraphSource::DSGraphSource() : Inherited(),
    mStreamGroupOutput(0),
    mBuilt(false)
{
}

//********************************************************************
//
//********************************************************************
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
bool DSGraphSource::init()
{
    bool bOK = true;

    if (!isOk())
    {
        bOK = Inherited::init();

        mBuilt = false;
        mStreamGroupOutput = NEW NWStreamGroupWrite();
        bOK = mStreamGroupOutput->init("GraphSource Output");
    }
    return bOK;

}

//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
void DSGraphSource::done()
{
    if (isOk())
    {
        mStreamGroupOutput->disableWrite(true);
        Inherited::done();
        DISPOSE(mStreamGroupOutput);
    }
}

//********************************************************************
//
//********************************************************************
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
INWStreamGroupWrite* DSGraphSource::getStreamGroupOutput()
{
    return mStreamGroupOutput;
}


//********************************************************************
//
//********************************************************************
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
/*bool DSGraphSource::inputGraphConnected()
{
    return connectFiltersRender();
}*/
bool DSGraphSource::build()
{
    return true;
}

//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
bool DSGraphSource::postBuild()
{
    bool ok = true;

    ASSERT(!mBuilt);

    if ( !mBuilt )
    {
        ok = connectFiltersRender();
        mBuilt = true;
    }

    return ok;
}